<%@ page language="java" import="java.util.*"  pageEncoding="utf-8"%>
<%@include file="common/indexhead.jsp" %>
<%@include file="common/tag.jsp" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!-- <meta content="text/html; charset=utf-8" http-equiv="Content-Type"/> -->
<div class="panel panel-primary" >  
	<div class="panel-heading">  
		<div>
		<h3 class="panel-title">${businesstype}管理</h3> 
		</div>
		<div class="button" style="float: right;margin-top: -27px;margin-right: 5px;">
			<a class="btn btn-info" href="/business/add" target="_blank"><i class="fa fa-plus-square"></i>新增${businesstype}</a>
		</div>
	</div> 
	<%-- <jsp:include page="tree.jsp"></jsp:include> --%>
	<div class="panel-body"  style="height:87%">
		<div style="height:85%">
		<table class="table table-hover">
			<thead>
				<tr>
					<th>单位名称</th>
					<th>开户行</th>
					<th>联系人</th>
					<th>联系电话</th>
					<th>创建时间</th>
					<th>详情</th>
					<th class="mydelete">删除</th>
					</tr>
			</thead>
			<tbody>
				<c:forEach var="business" items="${businesslist}">
					<tr>
						<td>${business.businessDwmc}</td>
						<td>${business.businessKhyh}</td>
						<td>${business.businessLxr}</td>
						<td>${business.businessDh}</td>
						<td><fmt:formatDate value="${business.createTime}" pattern="yyyy-MM-dd"/></td>
						<td style="width:10px"><a class="btn btn-info"  href="/business/${business.businessId}/detail"  target="_blank">详情</a></td>
						<td class="mydelete" style="width:10px"><a class="btn btn-danger" onclick="tijiao('${business.businessId}')" href="#">删除</a></td>
					</tr>
				</c:forEach>  
				<%-- onclick="window.parent.changeIframe('/user/${us.userId}/detail')"   --%>
			</tbody>
		</table>
		</div>
		<hr></hr>
		<div style="margin-top:-30px" id="resultlist" >
	
		</div>
	</div>
</div>

<!-- 弹出框重写 -->
<div id="ycf-alert" class="modal">
      <div class="modal-dialog modal-sm">
        <div class="modal-content">
          <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
            <h5 class="modal-title"><i class="fa fa-exclamation-circle"></i> [Title]</h5>
          </div>
          <div class="modal-body small">
            <p>[Message]</p>
          </div>
          <div class="modal-footer" >
            <button type="button" class="btn btn-primary ok" data-dismiss="modal">[BtnOk]</button>
            <button type="button" class="btn btn-default cancel" data-dismiss="modal">[BtnCancel]</button>
          </div>
        </div>
      </div>
    </div>
<!-- 弹出框重写end -->

<%@include file="common/indexbottom.jsp" %>
<script type="text/javascript">
/*  Modal.confirm(
{
    msg: "是否删除角色？"
}) 
Modal.alert(
            {
                msg: res['msg'],
                title: '操作',
                btnok: '确定',
                btncl:'取消'
            });*/
$(function() {
if("<%=request.getSession().getAttribute("userid")%>"!="admin"){
	$(".mydelete").hide();
}
window.Modal = function() {
    var reg = new RegExp("\\[([^\\[\\]]*?)\\]", 'igm');
    var alr = $("#ycf-alert");
    var ahtml = alr.html();

    var _alert = function(options) {
        alr.html(ahtml); // 复原
        alr.find('.ok').removeClass('btn-success').addClass('btn-primary');
        alr.find('.cancel').hide();
        _dialog(options);

        return {
            on: function(callback) {
                if (callback && callback instanceof Function) {
                    alr.find('.ok').click(function() {
                        callback(true)
                    });
                }
            }
        };
    };

    var _confirm = function(options) {
        alr.html(ahtml); // 复原
        alr.find('.ok').removeClass('btn-primary').addClass('btn-success');
        alr.find('.cancel').show();
        _dialog(options);

        return {
            on: function(callback) {
                if (callback && callback instanceof Function) {
                    alr.find('.ok').click(function() {
                        callback(true)
                    });

                }
            }
        };
    };

    var _dialog = function(options) {
        var ops = {
            msg: "提示内容",
            title: "操作提示",
            btnok: "确定",
            btncl: "取消"
        };

        $.extend(ops, options);

        console.log(alr);

        var html = alr.html().replace(reg,
        function(node, key) {
            return {
                Title: ops.title,
                Message: ops.msg,
                BtnOk: ops.btnok,
                BtnCancel: ops.btncl
            } [key];
        });

        alr.html(html);
        alr.modal({
            width: 500,
            backdrop: 'static'
        });
    }

    return {
        alert: _alert,
        confirm: _confirm
    }

} ();
});

function tijiao(Id) {
Modal.confirm({
    msg: "是否删除该${businesstype}？"
}).on(function(e) {
    $.ajax({
        type: "get",
        url: yongan.URL.businessDelete(Id),
        dataType: "json",
        data: {},
        success: function(data) {

            if (data['success']) {
                Modal.alert({
                    msg: data['data']['stateinfo'],
                    title: '执行结果',
                    btnok: '确定',
                    btncl: '取消'
                }).on(function(e) {
                    parent.changeIframe(yongan.URL.businessList());
                });
            }
        },
        error: function(XMLHttpRequest, textStatus, errorThrown) {
            alert(XMLHttpRequest);
            alert(textStatus);
            alert(errorThrown);
        }
    });
});
}


fenye(${pb.currentPage},${pb.totalPages},${pb.totalRecords},${pb.pagesize},"/business/0/businesslist");
</script>